<template>
  <div class="chat-window">
    <div class="chat-title text-elip">
      <span class="text">美女</span>
      <div class="more">
        <Icon type="ios-more" />
      </div>
    </div>
    <div class="split-div">
      <Split v-model="split" mode="vertical">
        <div slot="top" class="split-pane">
          <vue-scroll>
            <left-msg-box></left-msg-box>
            <left-msg-box></left-msg-box>
            <left-msg-box></left-msg-box>
            <left-msg-box></left-msg-box>
            <right-msg-box></right-msg-box>
            <right-msg-box></right-msg-box>
            <right-msg-box></right-msg-box>
            <left-msg-box></left-msg-box>
            <left-msg-box></left-msg-box>
            <right-msg-box></right-msg-box>
            <right-msg-box></right-msg-box>
          </vue-scroll>
        </div>
        <div slot="bottom" class="split-pane">
          <div class="tool-bar">
            <div style="float:left;">
              <Icon type="ios-analytics-outline" title="表情" />
              <Icon type="ios-folder-outline" title="发送文件" />
              <Icon type="ios-cut-outline" title="剪切(Alt+A)" />
              <Icon type="ios-chatboxes-outline" title="聊天记录" />
            </div>
            <div style="float:right;">
              <Icon type="ios-call-outline" title="语音聊天" />
              <Icon type="ios-videocam-outline" title="视频聊天" />
            </div>
          </div>
          <div class="input-div" @click="keepLastIndex($refs.inputBox)">
            <vue-scroll>
              <div ref="inputBox" class="edit-div" contenteditable="plaintext-only"></div>
            </vue-scroll>
          </div>
          <div class="btn-div">
            <Button class="btn-send" type="success" size="small">发送(S)</Button>
          </div>
        </div>
      </Split>
    </div>

    <!-- <div class="msg-div">
      <vue-scroll>
        <left-msg-box></left-msg-box>
        <left-msg-box></left-msg-box>
        <left-msg-box></left-msg-box>
        <left-msg-box></left-msg-box>
        <right-msg-box></right-msg-box>
        <right-msg-box></right-msg-box>
        <right-msg-box></right-msg-box>
        <left-msg-box></left-msg-box>
        <left-msg-box></left-msg-box>
        <right-msg-box></right-msg-box>
        <right-msg-box></right-msg-box>
      </vue-scroll>
    </div>
    <div class="send-div">
      <div class="tool-bar">
        <div style="float:left;">
          <Icon type="ios-analytics-outline" title="表情" />
          <Icon type="ios-folder-outline" title="发送文件" />
          <Icon type="ios-cut-outline" title="剪切(Alt+A)" />
          <Icon type="ios-chatboxes-outline" title="聊天记录" />
        </div>
        <div style="float:right;">
          <Icon type="ios-call-outline" title="语音聊天" />
          <Icon type="ios-videocam-outline" title="视频聊天" />
        </div>
      </div>
      <div class="input-div" @click="keepLastIndex($refs.inputBox)">
        <vue-scroll>
          <div ref="inputBox" class="edit-div" contenteditable="plaintext-only"></div>
        </vue-scroll>
      </div>
      <div class="btn-div">
        <Button class="btn-send" type="success" size="small">发送(S)</Button>
      </div>
    </div> -->
  </div>
</template>

<script>
import LeftMsgBox from '../../components/myChat/msgBox/LeftMsgBox'
import RightMsgBox from '../../components/myChat/msgBox/RightMsgBox'
export default {
  components: { LeftMsgBox, RightMsgBox },
  data() {
    return {
      split: 0.6,
      msg: ''
    }
  },
  methods: {
    keepLastIndex(obj) {
      console.log('keep')
      obj.focus()
      // var range = window.getSelection() //创建range
      // range.selectAllChildren(obj) //range 选择obj下所有子内容
      // range.collapseToEnd() //光标移至最后
    }
  }
}
</script>

<style scoped>
.chat-window {
  position: absolute;
  top: 0;
  left: 250px;
  bottom: 0;
  right: 0;
  background-color: #ebeef5;
}

.chat-title {
  position: absolute;
  box-sizing: border-box;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  line-height: 36px;
  font-size: 18px;
  padding-right: 40px;
  padding-left: 20px;
  border-bottom: 1px solid #c0c4cc;
  -webkit-app-region: drag;
  -webkit-user-select: none;
}

.chat-title .more {
  position: absolute;
  top: 3px;
  right: 10px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  width: 30px;
  color: #909399;
  font-size: 20px;
  cursor: pointer;
  -webkit-app-region: no-drag;
}

.chat-title .more:hover {
  color: #303133;
}

.chat-title .text {
  cursor: pointer;
  -webkit-app-region: no-drag;
}

.split-div {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  bottom: 0;
}

.split-pane {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.tool-bar {
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 36px;
  line-height: 36px;
  font-size: 20px;
  color: #909399;
}

.tool-bar i {
  cursor: pointer;
  margin-right: 15px;
}

.tool-bar i:hover {
  color: #303133;
}

.input-div {
  position: absolute;
  top: 36px;
  left: 20px;
  right: 10px;
  bottom: 40px;
  cursor: text;
}

.edit-div {
  padding-right: 12px;
}

.btn-div {
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 40px;
}

.btn-send {
  float: right;
  margin-top: 6px;
}
</style>
